package fr.axones.pocketagile.services.remote
{	
	import flash.net.URLRequestMethod;
	
	import fr.axones.pocketagile.services.remote.util.ResultHandler;
	import fr.axones.pocketagile.vo.ProjectItemVO;
	import fr.axones.pocketagile.vo.ProjectUserVO;
	import fr.axones.pocketagile.vo.ProjectVO;
	import fr.axones.pocketagile.vo.UserVO;
	
	import mx.rpc.AsyncToken;
	
	import org.spicefactory.lib.reflect.types.Void;

	public class ProjectItemService
	{
		public function ProjectItemService()
		{
		}
		
		/**
		 * Add the project item
		 */
		public function addProjectItem(pi:ProjectItemVO):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doPost("http://axplanningpoker.appspot.com/rest/item",JSON.stringify(pi));
			
			return result.token;
		}
		
		/**
		 * Delete the project item
		 */
		public function deleteProjectItem(itemId:Number):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doDelete("http://axplanningpoker.appspot.com/rest/item/"+itemId);

			return result.token;
		}
		
		/**
		 * Update the project item
		 */
		public function updateProjectItem(pi:ProjectItemVO):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doPut("http://axplanningpoker.appspot.com/rest/item",JSON.stringify(pi));

			return result.token;
		}
	}
}